#include<iostream>
using namespace std;
int main(){
	long long f[1001];
	f[0] = 1;
	f[1] = 1;
	for(int i = 2; i <= 1000; i = i + 1){
		// f[i] = (f[i - 1] % 9997 + f[i - 2] % 9997) % 9997;
		f[i] = f[i - 1] + f[i - 2] ;
	}
	
	for (int i=0; i<1001; i++) {
		cout << i << "\t\t\t" << f[i] << endl;
	}
	
	freopen("fib.in", "r", stdin);
	freopen("fib.out", "w", stdout);
	int n;
	while (cin >> n){
		if(n < 1 || n > 1000){
			cout << endl;
		}
		int ans = f[n-1] % 9997;
		cout << ans << endl;
	}
	
	return 0;
}
